package com.bw.shop2208a.mvvm

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider

/**
 * base层---fragment
 */
abstract class BaseViewFragment<VDB : ViewDataBinding> : Fragment() {
    //lateinit var 延迟初始化  格式 名称：类型  没有等号   可以在合适的地方进行初始化赋值
    lateinit var binding: VDB
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(layoutInflater, getLayoutId(), container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initViwe()
        iniData()
    }

    abstract fun initViwe()
    abstract fun iniData()
    abstract fun getLayoutId(): Int
}